//
//  HFCsIrJLCFHomeNewBmapCellwxSIog.m
//  Jlcf_ios
//
//  Created by Ji on 2018/9/27.
//  Copyright © 2018 ski. All rights reserved.
//

#import "HFCsIrJLCFHomeNewBmapCellwxSIog.h"
#import "zzknojJLCFListDetailViewControllerFwedjf.h"
#import "rmMqyfJLCFLoginAndRegisterControllerFbzYtj.h"

@interface HFCsIrJLCFHomeNewBmapCellwxSIog ()

@property (nonatomic, strong) UIImageView *KxPjREattachImgQnJZLA;

@property (nonatomic, strong) UILabel *lHLQaCcategoryLabelrFFGMy;

@property (nonatomic, strong) UILabel *edHyphtipsLabelTVYPVW;

@property (nonatomic, strong) UIImageView *szXnJCbmapBgImgyxRdDG;

@property (nonatomic, strong) UILabel *titleLabel;

@property (nonatomic, strong) UILabel *DqlqILaprLabelIPueGU;

@property (nonatomic, strong) UILabel *uBShqXnoticeLabelBqMXlb;

@property (nonatomic, strong) UIButton *buyBtn;

@end

@implementation HFCsIrJLCFHomeNewBmapCellwxSIog

- (void)reloadData
{
    self.backgroundColor = QTZ_White;
    if (self.model) {
        
        if (!self.KxPjREattachImgQnJZLA) {
            self.KxPjREattachImgQnJZLA = [[UIImageView alloc] initWithFrame:CGRectMake(15, 12, 5, 15)];
//            self.KxPjREattachImgQnJZLA.backgroundColor = RGB(249, 205, 33);
            self.KxPjREattachImgQnJZLA.image = [UIImage imageNamed:@"icon_home_KxPjREattachImgQnJZLA"];
            [self addSubview:self.KxPjREattachImgQnJZLA];
        }
        
        if (!self.lHLQaCcategoryLabelrFFGMy) {
            self.lHLQaCcategoryLabelrFFGMy = [UILabel labelWithText:@"新手专享" textColor:QTZ_Gray51 font:FONT(11)];
            self.lHLQaCcategoryLabelrFFGMy.centerY = self.KxPjREattachImgQnJZLA.centerY;
            self.lHLQaCcategoryLabelrFFGMy.left = self.KxPjREattachImgQnJZLA.right + 7;
            [self addSubview:self.lHLQaCcategoryLabelrFFGMy];
        }
        
        if (!self.edHyphtipsLabelTVYPVW) {
            self.edHyphtipsLabelTVYPVW = [UILabel labelWithText:@"收益这么高，大家都在投" textColor:QTZ_Gray153 font:FONT(7)];
            self.edHyphtipsLabelTVYPVW.centerY = self.KxPjREattachImgQnJZLA.centerY;
            self.edHyphtipsLabelTVYPVW.left = self.lHLQaCcategoryLabelrFFGMy.right + 9;
            [self addSubview:self.edHyphtipsLabelTVYPVW];
        }
        
        if (!self.szXnJCbmapBgImgyxRdDG) {
            self.szXnJCbmapBgImgyxRdDG = [[UIImageView alloc] initWithFrame:CGRectMake(18, 40, FULL_WIDTH - 36, 165)];
//            self.szXnJCbmapBgImgyxRdDG.image = [UIImage imageNamed:@"icon_home_newBg"];
            self.szXnJCbmapBgImgyxRdDG.userInteractionEnabled = YES;
            [self addSubview:self.szXnJCbmapBgImgyxRdDG];
        }
        
        if (!self.titleLabel) {
            self.titleLabel = [UILabel new];
            self.titleLabel.font = FONT(8);
            self.titleLabel.textColor = QTZ_Gray102;
            self.titleLabel.text = @"预期年化收益";
            [self.titleLabel sizeToFit];
            self.titleLabel.top = 20;
            self.titleLabel.centerX = self.szXnJCbmapBgImgyxRdDG.width / 2;
            [self.szXnJCbmapBgImgyxRdDG addSubview:self.titleLabel];
        }
        
        if (!self.DqlqILaprLabelIPueGU) {
            self.DqlqILaprLabelIPueGU = [UILabel new];
            self.DqlqILaprLabelIPueGU.textColor = Theme_Color;
            self.DqlqILaprLabelIPueGU.font = FONT(23);
            [self.szXnJCbmapBgImgyxRdDG addSubview:self.DqlqILaprLabelIPueGU];
        }
        
        if (self.DqlqILaprLabelIPueGU) {
            if ([self.model.addApr isEqualToString:@"0"]) {
                self.DqlqILaprLabelIPueGU.text = [NSString stringWithFormat:@"%@%%", self.model.realApr];
            } else {
                self.DqlqILaprLabelIPueGU.text = [NSString stringWithFormat:@"%@%%+%@%%", self.model.realApr, self.model.addApr];
            }
            [self.DqlqILaprLabelIPueGU sizeToFit];
            self.DqlqILaprLabelIPueGU.centerX = self.titleLabel.centerX;
            self.DqlqILaprLabelIPueGU.top = self.titleLabel.bottom + 12 ;
        }
        
        if (!self.uBShqXnoticeLabelBqMXlb) {
            self.uBShqXnoticeLabelBqMXlb = [UILabel new];
            self.uBShqXnoticeLabelBqMXlb.textColor = QTZ_Gray102;
            self.uBShqXnoticeLabelBqMXlb.font = FONT(8);
            [self.szXnJCbmapBgImgyxRdDG addSubview:self.uBShqXnoticeLabelBqMXlb];
        }
        
        if (self.uBShqXnoticeLabelBqMXlb) {
            self.uBShqXnoticeLabelBqMXlb.text = [NSString stringWithFormat:@"%@天期限   |   %@起投   |   剩余可投%@元", self.model.timeLimitDay, self.model.lowestAccount, self.model.remmoney];
            [self.uBShqXnoticeLabelBqMXlb sizeToFit];
            self.uBShqXnoticeLabelBqMXlb.centerX = self.titleLabel.centerX;
            self.uBShqXnoticeLabelBqMXlb.top = self.DqlqILaprLabelIPueGU.bottom+15;
        }
        
        if (!self.buyBtn) {
            self.buyBtn = [[UIButton alloc] initWithFrame:CGRectMake(0, self.uBShqXnoticeLabelBqMXlb.bottom + 15, 160, 30)];
            self.buyBtn.centerX = self.DqlqILaprLabelIPueGU.centerX;
            self.buyBtn.titleLabel.font = FONT(10);
            [self.buyBtn setBackgroundColor:Theme_Color];
            [self.buyBtn setTitle:@"立即投资" forState:0];
            self.buyBtn.layer.cornerRadius = 15;
            [self.buyBtn bk_whenTapped:^{
                
                if ([JLCFRegisterService shareService].hasToken){
                    zzknojJLCFListDetailViewControllerFwedjf *detailVC = [zzknojJLCFListDetailViewControllerFwedjf new];
                    detailVC.bxiKZJproTitlehvcALF = self.model.name;
                    detailVC.proId = self.model.id;
                    [[[JinLiCaiFuApplicationEntrace shareEntrance] currentNavController] pushViewController:detailVC animated:YES];
                }else{
                    rmMqyfJLCFLoginAndRegisterControllerFbzYtj *vc = [rmMqyfJLCFLoginAndRegisterControllerFbzYtj new];
                    
                    if (![[JinLiCaiFuApplicationEntrace shareEntrance] isContainVC:@"LoginAndRegisterController"]) {
                        [[[JinLiCaiFuApplicationEntrace shareEntrance] currentNavController] pushViewController:vc animated:YES];
                        [vc showNotice:@"请登陆或注册"];
                    }
                }
            }];
            [self.szXnJCbmapBgImgyxRdDG addSubview:self.buyBtn];
        }
        
    }
    
}



@end
